<?php
/**
* @package HelloWorld
* @version 1.0
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software and parts of it may contain or be derived from the
* GNU General Public License or other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

/*
 * DEVNOTE: This is the 'main' file. 
 * It's the one that will be called when we go to the HELLOWORD component. 
 */
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/*
 * Make sure the user is authorized to view this page
 */
/* get rid of it...must be changed in libraries\joomla\user\authorization.php 
$user = & JFactory::getUser();
   
if (!$user->authorize( 'com_helloword', 'manage' )) {
	$mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
}
*/
// Load the html class
// DEVNOTE: This will include the admin.helloworld.html.php file, 
// so now we can use anything that it provides!
//require_once( JApplicationHelper::getPath( 'admin_html' ) ); 
//No more helpers. these funcions were moved to controlers an views.



// specific controller?
 if($controller = JRequest::getVar('controller')) 
// Require specific controller if requested
  {
   require_once (JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php');
   require_once( JPATH_COMPONENT.DS.'models'.DS.'hotels.php' );
   require_once( JPATH_COMPONENT.DS.'views'.DS.$controller.DS.'view.php' );
  }
 else 
// Require the base controller - default
  {
  require_once (JPATH_COMPONENT.DS.'controllers'.DS.'default.php');
  require_once( JPATH_COMPONENT.DS.'models'.DS.'hotels.php' );
  require_once (JPATH_COMPONENT.DS.'views'.DS.'default'.DS.'view.php');

  }
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_hotels'.DS.'tables');
// Create the controller
$classname  = 'HotelsController'.$controller;
//echo $classname;
//echo JRequest::getVar('task' );
$controllerName = JRequest::getCmd( 'controller' );
if($controllerName == 'destination') {
	JSubMenuHelper::addEntry(JText::_('Hotels'), 'index.php?option=com_hotels');
	JSubMenuHelper::addEntry(JText::_('Destination'), 'index.php?option=com_hotels&controller=destination', true );
} else {
	JSubMenuHelper::addEntry(JText::_('Hotels'), 'index.php?option=com_hotels', true );
	JSubMenuHelper::addEntry(JText::_('Destination'), 'index.php?option=com_hotels&controller=destination');
}
//exit;
$controller = new $classname( array('default_task' => 'display') );
//$controller = new $classname();

// Perform the Request task
$controller->execute( JRequest::getVar('task' ));

// Redirect if set by the controller
$controller->redirect();

 
?>
